Imports System
Imports NUnit.Framework
Imports ValidationFramework

Namespace ParameterValidationManagerExamples
    Public Class BasicHandleExample
#Region "Example"

        Public Class Person
            ' Methods
            Public Sub CheckAge( _
                                <CompareIntRule(5, CompareOperator.LessThan)> ByVal age As Int32)
                ParameterValidationManager.ThrowException(Me, checkAgeHandle, age)
                '' business code goes here.
            End Sub


            Private Shared ReadOnly checkAgeHandle As RuntimeMethodHandle = _
                                        GetType(Person).GetMethod("CheckAge").MethodHandle

        End Class

        <TestFixture()> _
        Public Class ExampleUsage
            <ExpectedException(GetType(ArgumentException)), Test()> _
            Public Sub RunInvalidData()

                Dim person As New Person()
                person.CheckAge(7)
            End Sub

            <Test()> _
            Public Sub RunValidData()
                Dim person As New Person()
                person.CheckAge(2)
            End Sub

        End Class
#End Region
    End Class
End Namespace